package utils;
public class XmlReplace {
    public static String escape( String text ) {
    	if(text==null) return "";
    	String t=text;
    	t=t.replace("&", "&amp;");
    	t=t.replace("<", "&lt;");
    	t=t.replace(">", "&gt;");
    	t=t.replace("\"", "&quot;");
    	
    	
    	return t;
    }

    public static String unescape( String text ) {
    	if(text==null) return "";
    	String t=text;
    	t=t.replace("&amp;","&");
    	t=t.replace("&lt;","<");
    	t=t.replace("&gt;",">");
    	t=t.replace("&quot;","\"");
    	
    	
    	return t;
    }

    
    public static void main(String[] args) {
    	String embed = "<object width=\"1280\" height=\"745\"><param name=\"movie\" value=\"http://www.youtube.com/v/g2-cd2ipOVA&hl=en_US&fs=1&\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"http://www.youtube.com/v/g2-cd2ipOVA&hl=en_US&fs=1&\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"1280\" height=\"745\"></embed></object>";
		embed = XmlReplace.escape(embed);
    	String xml = "<xml><clip id='1234' title='clip vui ne' embeb='"+embed+"'></clip></xml>";
		System.out.println(xml);
    }
  
}
